<template>
  <div class="app-content">
    <div class="app-content__heard">
        <div class="heard--service">
          <img src="../assets/prev.png" alt="" @click="huitui">
        </div>
        <div class="heard--search">
          <img src="../assets/sousuo.png" alt="">
          <input type="text" autocomplete="off" placeholder="保暖内衣" v-model="search">
        </div>
        <div class="heard--Shopping">
          <span @click="go">搜索</span>
        </div>
      </div>
    <div class="app-content--box">
      <div class="app-content--box__Tips">热搜</div>
      <div class="Historical">
        <span>保暖内衣</span>
        <span>面膜</span>
        <span>口红</span>
        <span>手表</span>
        <span>保温杯</span>
        <span>洗衣液</span>
        <span>超值大礼包</span>
        <span>华为</span>
        <span>耳机</span>
      </div>
      <div class="block"></div>
      <div class="Record--box">
        <span>历史搜索</span>
        <span><img src="../assets/del.png" alt="" class="Record--box__img" @click="del"></span>
      </div>
      <span class="HistoricalRecord" v-for="(item, key) in this.$store.state.arr" :key="key">{{item}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "HotSearch",
  data() {
    return {
      arr: [],
      search : '',
      res: '',
      array: [],
      xx: [],
    }
  },
  methods: {
    huitui(){
      this.$router.go(-1);
    },
    go(){
      this.$store.state.a = this.search;
      console.log(this.$store.state.a);

      this.xx.push(this.search);
      this.$store.state.arr = this.xx;

      this.$apis.searchProd({
        keyword: this.search,
      })
        .then(data => {
          this.$router.push({name: 'SearchRecord', params: {
            data: data.data.data,
          }});
          console.log(data);
        })
        .catch(error => {
          console.log(error);
        })
    },
    del(){
      this.$store.state.arr = '';
    }
  },
}
</script>

<style scoped>
  .app-content{
    width: 100vw;
    height: 100vh;
  }
  .app-content__heard{
    width: 100vw;
    height: 1.1rem;
    border-bottom: #f7f7f7 1px solid;
    background: white;
  }
  .heard--service{
    display: inline-block;
    width: 1.3066rem;
    height: 1.1rem;
    margin-top: -3px;
  }
  .heard--service>img{
    width: .6rem;
    height: .6rem;
    position: relative;
    left: .2rem;
    top: .3rem;
  }
  .heard--search{
    display: inline-block;
    width: 7.45333rem;
    height: .8533rem;
    background: #f5f5f5;
    border-radius: .2rem;
    margin-left: -.3rem;
  }
  .heard--search>img{
    display: inline-block;
    width: .4366rem;
    height: .4366rem;
    position: relative;
    top: .19rem;
    left: .2rem;
  }
  .heard--search>input{
    display: inline-block;
    position: relative;
    width: 5rem;
    height: .4366rem;
    left: .5rem;
    top: .1rem;
    font-size: .35rem;
    border: none;
    outline: none;
    background: #f5f5f5;
  }
  .heard--Shopping{
    display: inline-block;
    width: 1.2rem;
    height: 1.1rem;
  }
  .heard--Shopping>span{
    font-size: 32px;
    display: inline-block;
    color: #dadada;
    margin-left: 10px;
    position: relative;
    top: 10px;
  }
  .app-content--box{
    width: 100vw;
    height: 309px;
  }
  .app-content--box__Tips{
    width: 100vw;
    height: 100px;
    font-size: 29px;
    text-indent: 30px;
    line-height: 100px;
  }
  .Historical{
    margin-top: -40px;
  }
  .Historical>span{
    display: inline-block;
    line-height: 51px;
    border: 1px solid #dbdbdb;
    width: 109px;
    font-size: 27px;
    text-align: center;
    color: #5d5d5d;
    border-radius: 9px;
    margin-left: 30px;
    margin-top: 34px;
  }
  .Historical>span:nth-child(1){
    width: 159px;
  }
  .Historical>span:nth-child(7){
    width: 188px;
  }
  .block{
    width: 100vw;
    height: 15px;
    background: #f2f2f2;
    margin-top: 18px;
  }
  .Record--box{
    width: 99vw;
    height: 96px;
    line-height: 96px;
    text-indent: 30px;
    font-size: 29px;
    border: 1px solid #f7f7f7;
  }
  .Record--box__img{
    display: inline-block;
    width: .5rem;
    position: absolute;
    right: 30px;
    top: 460px;
    margin: auto;
  }
  .HistoricalRecord{
    display: inline-block;
    width: 100vw;
    height: 96px;
    line-height: 96px;
    color: #626262;
    font-size: 27px;
    text-indent: 30px;
    border-bottom: 1px solid #f7f7f7;
  }
</style>
